<template>
  <div>
    <h1>Communication with Main Process</h1>
    <button @click="sendMessageToMain">Send Message to Main</button>
    <p>Received message from main process: {{ receivedMessage }}</p>

    <button @click="upload_file">上传文件并插入数据库</button>
  </div>
</template>

<script>

// import { ipcRenderer } from 'electron';

export default {
  name: 'MyComponent',
  data() {
    return {
      receivedMessage: '',
    };
  },
  methods: {
    sendMessageToMain() {
      window.send_main.query_db('SELECT * FROM users', (result) => {
        // 处理查询结果
        this.receivedMessage = result
        console.log(result);
      });
    },
    setupIPCListener() {
      // ipcRenderer.on('message-from-main', (event, message) => {
      //   this.receivedMessage = message;
      // });
    },
    upload_file(){
      window.send_main.upload_file_to_db('123',(result) => {
        console.log(result);
      })
    }
  },
  created() {
    this.setupIPCListener();
  },
};
</script>

<style scoped>
/* 样式定义 */
</style>




<template>
  <el-table v-loading="loading" :data="tableData" style="width: 100%">
    <el-table-column prop="date" label="Date" width="180" />
    <el-table-column prop="name" label="Name" width="180" />
    <el-table-column prop="address" label="Address" />
  </el-table>
</template>

<script lang="ts" setup>
import { ref } from 'vue'

const loading = ref(true)

const tableData = [
  {
    date: '2016-05-02',
    name: 'John Smith',
    address: 'No.1518,  Jinshajiang Road, Putuo District',
  },
  {
    date: '2016-05-04',
    name: 'John Smith',
    address: 'No.1518,  Jinshajiang Road, Putuo District',
  },
  {
    date: '2016-05-01',
    name: 'John Smith',
    address: 'No.1518,  Jinshajiang Road, Putuo District',
  },
]
</script>

<style>
body {
  margin: 0;
}
.example-showcase .el-loading-mask {
  z-index: 9;
}
</style>
